#include <iostream>
#include <string>

using namespace std;

int main()
{
    int c = 0;
    string opening_brackets = "([{<";
    string closing_brackets = ")]}>";
    string s;
    cout << "Введите последовательность строк:" << endl;
    cin >> s;
    string stek = "";
    for(char i: s){
        if (opening_brackets.find(i) != std::string::npos) {
            stek = stek + i;
            continue;
        }
        if (closing_brackets.find(i) != std::string::npos) {
            if (stek.length() == 0) {
                stek = stek + i;
                break;
            }
            if (stek[stek.length()-1] == opening_brackets[closing_brackets.find(i)]) {
                stek.pop_back();
            }
            else {
                break;
            }
        }
    }
    if (stek.length() == 0)
        {cout << "True";}
    else {cout << "False";}
}
